#ifndef OBJECT_H_
#define OBJECT_H_

// INCLUDES //
#include "physics/path.h"
#include "graphics/graphics.h"
#include "graphics/surface.h"
#include "physics/area.h"
#include <vector.h>
//////////////

// OBJECT IDS //
#define OBJECT_ID_NONE			0
#define OBJECT_ID_CARD			1
#define OBJECT_ID_ALIGNMENT		2
#define OBJECT_ID_RED_GEM		(int)'R'
#define OBJECT_ID_GREEN_GEM		(int)'G'
#define OBJECT_ID_BLUE_GEM		(int)'B'
#define OBJECT_ID_YELLOW_GEM	(int)'Y'
#define OBJECT_ID_WHITE_GEM		(int)'W'
#define OBJECT_ID_BLACK_GEM		(int)'L'
////////////////

/**
* Contains the location, size, and path of an object in Xyne. It also
* keeps track of it's associations, which get special treatment by the physics engine.
* 
* @author dfoelber
**/
class Object
{
public:
	/**
	* Constructor
	* 
	* @param image the image the object shows to the player
	* @param id the meta ID for the object
	* @param owner if the object is the owner of the surface (for cleanup)
	* @param autoAdd automatically adds the object to the render manager
	**/
	Object( Surface* image, int id = OBJECT_ID_NONE, bool owner = false, bool autoAdd = true );
	
	/**
	* Deconstructor
	**/
	virtual ~Object();
	
	/**
	* Returns the object's ID
	**/
	int GetID();
	
	/**
	* Checks if the object is dirty and needs a redraw.
	* 
	* @return If the object is dirty
	**/
	bool IsDirty();
	
	/**
	* Declares the object to be clean.
	**/
	void SetClean();
	
	/**
	* Sets the object's hover state.
	* 
	* @param hover If the object is being hovered
	**/
	void SetHover( bool hover );
	
	/**
	* Gets the object's hover state.
	* 
	* @return If the object is being hovered
	**/
	bool IsHovered();
	
	/**
	* Sets the position of the underlying path. 
	* 
	* @param x x coordinate
	* @param y y coordinate
	**/
	void SetPosition( int x, int y );
	
	/**
	* Sets the object's image.
	* 
	* @param surface the new surface
	* @param owner if the surface transfers ownership
	**/
	void SetSurface( Surface* surface, bool owner );
	
	/**
	* Accessor to the object's image.
	* 
	* @return the surface
	**/
	virtual Surface* GetSurface();
	
	/**
	* Sets the object's background.
	* 
	* @param color the color
	* @param alpha the alpha
	**/
	void SetBackground( Color color, int alpha );
	
	/**
	* Accessor to the object's background (may be NULL).
	* 
	* @return the background
	**/
	virtual Surface* GetBackground();
	
	/**
	* Sets the object's path. Transfers ownership to the object.
	* 
	* @param path the new path
	**/
	void SetPath( Path* path );
	
	/**
	* Accessor to the object's path.
	* 
	* @return the path
	**/	
	Path* GetPath();
	
	/**
	* Adds another object to this object's association list. Transfers ownership to the object.
	* 
	* @param object the object to add
	**/	
	void AddAssociation( Object* object );
	
	/**
	* Removes a specific object to this object's association list.
	* 
	* @param object the object to remove
	**/		
	void RemoveAssociation( Object* object );
	
	/**
	* Removes all objects from this object's association list.
	**/		
	void RemoveAllAssociations();
	
	/**
	* Accessor to the object's association list.
	* 
	* @return the association list
	**/		
	const vector<Object*>& GetAssociations();
	
	/**
	* Invoked when the object is selected.
	**/
	virtual void OnSelection();
	
private:
	/// The image of the object
	Surface*			image;
	/// The background of the object
	Surface*			background;
	/// The path of the object
	Path*				path;
	/// The association list, a list of related objects
	vector<Object*>		associations;
	/// If the object is being hovered
	bool				hover;
	/// If the object is dirty and requires a redraw
	bool				dirty;
	/// ID of the object
	int					id;
	/// If the object owns the surface
	bool				owner;
};

#endif /*OBJECT_H_*/
